package com.platform.controller;

import com.platform.entity.SurveyAnswersEntity;
import com.platform.entity.SurveyEntity;
import com.platform.entity.SurveyQuestionEntity;
import com.platform.params.SurveyAnswerParams;
import com.platform.params.SurveyQuestionParams;
import com.platform.service.SurveyService;
import com.platform.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/survey")
public class SurveyController{

    @Autowired
    SurveyService apiSurveyService;

    /**
     * 新增调查表
     */
    @PostMapping("/saveSurvey")

    public R saveSurvey(@RequestParam(value = "title",required = false) String title, @RequestParam(value = "surveyDesc",required = false) String surveyDesc,
                        @RequestParam(value = "displayStatus",required = false) Integer displayStatus){
        SurveyEntity surveyVo = apiSurveyService.saveSurvey(title, surveyDesc, displayStatus);
        return R.ok().put("surveyVO",surveyVo);
    }

    /**
     * 新增问题表
     */
    @PostMapping("/saveSurveyQuestion")
    public R saveSurveyQuestion(@RequestBody List<SurveyQuestionParams> questionParamsList){
        List<SurveyQuestionEntity> surveyQuestionEntityList = apiSurveyService.saveSurveyQuestion(questionParamsList);
        return R.ok().put("surveyQuestionEntityList",surveyQuestionEntityList);
    }

    /**
     * 新增回答表
     */
    @PostMapping("/saveSurveyAnswer")
    public R saveSurveyAnswer(@RequestBody List<SurveyAnswerParams> answerParamsList){
        List<SurveyAnswersEntity> surveyAnswersEntityList = apiSurveyService.saveSurveyAnswer(answerParamsList);
        return  R.ok().put("SurveyQuestionVoList",surveyAnswersEntityList);
    }

    /**
     * 新增回答表
     */
//    @PostMapping("/saveSurveySelect")
//    public R saveSurveySelect(@RequestBody List<SurveyAnswerParams> answerParamsList){
//        List<SurveyAnswersEntity> SurveyQuestionVoList = apiSurveyService.saveSurveySelect(answerParamsList);
//        return R.ok().put("SurveyQuestionVoList",SurveyQuestionVoList);
//    }


    /**
     * 管理员对调查表获取分析统计结果
     */
    private Object analyse(){
        return "";
    }
    /**
     * 管理员查询调查表结果
     */
    public Object querySurvey(){
        return "";
    }

    /**
     * 管理员修改调查表问题
     */

    public Object updateSurveyQuesstion(){
        return "";
    }



    /**
     * 管理员修改调查表选项答案
     */

    public Object updateSurveyAnswer(){
        return "";
    }
    /**
     * 管理员修改调查表名称/描述
     */

    public Object updateSurveyTitleOrDesc(){
        return "";
    }
    /**
     * 管理员删除调查表
     */

    public Object deleteSurvey(){
        return "";
    }
    /**
     * 用户登录系统之后查询默认弹出调查表
     */

    public Object defaultSurvey(){
        return "";
    }
    /**
     * 用户提交调查表
     */

    public Object conmitSurvey(){
        return "";
    }

//    /**
//     * 添加调查表
//     */
//    @ApiOperation(value = "添加或更新调查表", response = Map.class)
//    @PostMapping("save")
//    public Object save(@RequestBody SurveyUserVo surveyUserVo) {
//        apiSurveyService.insertQuestionnaire(surveyUserVo);
//        return toResponsSuccess(surveyUserVo);
//    }

}
